package experiment.e03.code;

import java.util.Random;

/**
 * @author thinkpad - 83start
 * @version v1.0
 * @create 2022/9/29 15:57
 * @package experiment.e03.code
 * @description 回文数算法
 */

public class E05_PalindromeNumber {
    public static void main(String[] args) {
        // 生成五位数的数字
        String num = new Random().nextInt(9) + 1 + "";
        for (int i = 0; i < 4; i++) {
            num += new Random().nextInt(10);
        }
        num = "8109018";
        System.out.println( "原数：" + num);

        boolean flag = true;

        // 判断是否是素数
        for (int i = 0; i < num.length() / 2; i++) {
            if (num.charAt(i) != num.charAt(num.length() - 1 - i)) {
                flag = false;
                break;
            }
        }

        // 输出结果
        if (flag){
            System.out.println("是回文数");
        }else {
            System.out.println("不是回文数");
        }
    }
}
